export enum OrderStatusEnum {
  ALL = 0,
  PENDING_PAYMENT = 1,
  TO_BE_CONFIRMED = 2,
  TO_BE_DELIVERED = 3,
  IN_DELIVERY = 4,
  COMPLETED = 5,
  CANCELED = 6,
}

export const orderStatusList: Record<OrderStatusEnum, string> = {
  [OrderStatusEnum.ALL]: '全部订单',
  [OrderStatusEnum.PENDING_PAYMENT]: '待付款',
  [OrderStatusEnum.TO_BE_CONFIRMED]: '待接单',
  [OrderStatusEnum.TO_BE_DELIVERED]: '待派送',
  [OrderStatusEnum.IN_DELIVERY]: '派送中',
  [OrderStatusEnum.COMPLETED]: '已完成',
  [OrderStatusEnum.CANCELED]: '已取消',
};
export const isActionButtonVisible = (status: number, action: string) => {
  if (action === 'accept') {
    return status === OrderStatusEnum.TO_BE_CONFIRMED
  } else if (action === 'deliver') {
    return status === OrderStatusEnum.TO_BE_DELIVERED
  } else if (action === 'complete') {
    return status === OrderStatusEnum.IN_DELIVERY
  } else if (action === 'reject') {
    return status === OrderStatusEnum.TO_BE_CONFIRMED
  } else if (action === 'cancel') {
    return [OrderStatusEnum.TO_BE_DELIVERED, OrderStatusEnum.IN_DELIVERY].includes(status)
  } else {
    return false
  }
}
// 弹窗标题
export enum DialogTitleEnum {
  REJECT = "拒绝",
  CANCEL = "取消",
  DETAIL = "详细",
}
// 订单拒单理由
export const cancelOrderReasonList = [
  {
    value: 1,
    label: '订单量较多，暂时无法接单',
  },
  {
    value: 2,
    label: '菜品已销售完，暂时无法接单',
  },
  {
    value: 3,
    label: '餐厅已打烊，暂时无法接单',
  },
  {
    value: 0,
    label: '其他原因',
  },
]
// 订单取消理由
export const cancelrReasonList = [
  {
    value: 1,
    label: '订单量较多，暂时无法接单',
  },
  {
    value: 2,
    label: '菜品已销售完，暂时无法接单',
  },
  {
    value: 3,
    label: '骑手不足无法配送',
  },
  {
    value: 4,
    label: '客户电话取消',
  },
  {
    value: 0,
    label: '其他原因',
  },
]

// 订单状态
export const getOrderStatus = (status: number) => {
  const statusMap: Record<number, string> = {
    1: "待付款",
    2: "待接单",
    3: "待派送",
    4: "派送中",
    5: "已完成",
    6: "已取消",
  };
  return statusMap[status];
};
// 支付状态
export const getPayStatus = (status: number) => {
  const statusMap: Record<number, string> = {
    0: "未支付",
    1: "已支付",
    2: "已退款",
  };
  return statusMap[status];
};
export const getPayMethod = (status: number) => {
  const statusMap: Record<number, string> = {
    1: "支付宝",
    2: "微信",
  };
  return statusMap[status];
};
// 日期选择器 快速选择日期
export const shortcuts = [
  {
    text: '上一周',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      return [start, end]
    },
  },
  {
    text: '上一月',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      return [start, end]
    },
  },
]